92eb2b
@@ -917,10 +917,11 @@
public void copyToExternalBuffer(byte[] externalBuffer, int externalBufferStart)
   private void copyToBuffer(byte[] buffer, int bufferStart, int bufferLength) {
 
     final int fieldStart = currentFieldStart;
+    final int fieldLength = currentFieldLength;
     int k = 0;
-    for (int i = 0; i < bufferLength; i++) {
+    for (int i = 0; i < fieldLength; i++) {
       byte b = bytes[fieldStart + i];
-      if (b == escapeChar && i < bufferLength - 1) {
+      if (b == escapeChar && i < fieldLength - 1) {
         ++i;
         // Check if it's '\r' or '\n'
         if (bytes[fieldStart + i] == 'r') {
